﻿<UserControl x:Class="XamlHelpmeet.UI.Editors.GridCellEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:Converters="clr-namespace:XamlHelpmeet.UI.Converters"
             xmlns:helps="clr-namespace:XamlHelpmeet.UI.Utilities"
             xmlns:model="clr-namespace:XamlHelpmeet.Model;assembly=XamlHelpmeet.Model"
             DataContextChanged="UserControl_DataContextChanged">

    <UserControl.Resources>
        <Converters:ControlTypeEnumConverter x:Key="ControlTypeEnumConverter" />
        <ObjectDataProvider x:Key="ControlTypesDS"
                            MethodName="GetSortedEnumNames"
                            ObjectType="{x:Type helps:UIHelpers}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="model:ControlType" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    </UserControl.Resources>
    <UserControl.DataContext>
        <model:CellContent />
    </UserControl.DataContext>

    <Border Margin="5"
            BorderBrush="LightGray"
            BorderThickness="1"
            CornerRadius="10"
            Padding="5">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <ComboBox x:Name="cboControlType"
                      Width="Auto"
                      Focusable="False"
                      FontSize="10"
                      IsSynchronizedWithCurrentItem="True"
                      ItemsSource="{Binding Mode=OneWay,
                                            Source={StaticResource ControlTypesDS}}"
                      SelectedItem="{Binding ControlType,
                                             Converter={StaticResource ControlTypeEnumConverter},
                                             Mode=TwoWay}" />

            <Grid x:Name="editorContent"
                  Grid.Row="1" />

        </Grid>
    </Border>
</UserControl>